function DateTime(container) {
  this.id = container;
  this.value = '';
  this.uuid = Math.random().toString(36).substring(3, 8);
  this.picker;
  this.yearRow = '{value}年';
  this.monthRow = '{value}月';
  this.dayRow = '{value}日';
  this.hourRow = '{value}点';
  this.minuteRow = '{value}分';
  this.minYear = 1920;
  this.maxYear = 2030;
  // 初始化
  this.init = function() {
    this.ready();
  };
  this.ready = function() {
    var uuid = this.uuid
    document.querySelector(this.id).setAttribute('id', 'datetime-' + uuid)
    this.render()
  };
  //选项
  this.pickerOptions = function() {
    var _this = this;
    var options = {
      trigger: '#datetime-' + this.uuid,
      format: 'YYYY-MM-DD',
      value: _this.value,
      output: '.datetime_value',
      confirmText: '确定',
      cancelText: '取消',
      yearRow: _this.yearRow,
      monthRow: _this.monthRow,
      dayRow: _this.dayRow,
      hourRow: _this.hourRow,
      minuteRow: _this.minuteRow,
      onConfirm: function(value) {
        _this.value = value
      }
    }
    if (this.minYear) {
      options.minYear = this.minYear
    }
    if (this.maxYear) {
      options.maxYear = this.maxYear
    }
    return options

  };
  this.render = function() {
    this.picker = new DatetimePicker(this.pickerOptions());
  }
  this.init();
}
new DateTime('.app');
